package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.BsIntendedCustomersEntity;
import io.renren.modules.app.service.BsIntendedCustomersService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 意向客户表
 *
 */
@RestController
@RequestMapping("tb_bs_intended_customers/bsintendedcustomers")
public class BsIntendedCustomersController {
    @Autowired
    private BsIntendedCustomersService bsIntendedCustomersService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("tb_bs_intended_customers:bsintendedcustomers:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bsIntendedCustomersService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("tb_bs_intended_customers:bsintendedcustomers:info")
    public R info(@PathVariable("id") Long id){
        BsIntendedCustomersEntity bsIntendedCustomers = bsIntendedCustomersService.getIntendById(id);
		//BsIntendedCustomersEntity bsIntendedCustomers = bsIntendedCustomersService.getById(id);

        return R.ok().put("bsIntendedCustomers", bsIntendedCustomers);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("tb_bs_intended_customers:bsintendedcustomers:save")
    public R save(@RequestBody BsIntendedCustomersEntity bsIntendedCustomers){
        bsIntendedCustomersService.saveCustomer(bsIntendedCustomers);
		//bsIntendedCustomersService.save(bsIntendedCustomers);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("tb_bs_intended_customers:bsintendedcustomers:update")
    public R update(@RequestBody BsIntendedCustomersEntity bsIntendedCustomers){
        bsIntendedCustomersService.updateCustomer(bsIntendedCustomers);
		//bsIntendedCustomersService.updateById(bsIntendedCustomers);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("tb_bs_intended_customers:bsintendedcustomers:delete")
    public R delete(@RequestBody Long[] ids){
		bsIntendedCustomersService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
